#
# Copyright (c) 2011-2018 EditorConfig Team
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice,
#    this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright notice,
#    this list of conditions and the following disclaimer in the documentation
#    and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#

# Basic parser tests

# test repeat sections
new_ec_test_multiline(repeat_sections_ML basic.in a.a "option1=value1[ \t]*[\n\r]+option2=value2[ \t\n\r]*")
new_ec_test_multiline(basic_cascade_ML basic.in b.b "option1=c[ \t]*[\n\r]+option2=b[ \t\n\r]*")

# Tests for whitespace parsing

# test no whitespaces in property assignment
new_ec_test(no_whitespace whitespace.in test1.c "^key=value[ \t\n\r]*$")

# test single spaces around equals sign
new_ec_test(single_spaces_around_equals whitespace.in test2.c
    "^key=value[ \t\n\r]*$")

# test multiple spaces around equals sign
new_ec_test(multiple_spaces_around_equals whitespace.in test3.c
    "^key=value[ \t\n\r]*$")

# test spaces before property name
new_ec_test(spaces_before_property_name whitespace.in test4.c
    "^key=value[ \t\n\r]*$")

# test spaces before after property value
new_ec_test(spaces_after_property_value whitespace.in test5.c
    "^key=value[ \t\n\r]*$")

# test blank lines between properties
new_ec_test_multiline(blank_lines_between_properties_ML whitespace.in test6.c
    "key1=value1[ \t]*[\n\r]+key2=value2[ \t\n\r]*")

# test spaces in section name
new_ec_test(spaces_in_section_name whitespace.in " test 7 "
    "^key=value[ \t\n\r]*$")

# test spaces before section name are ignored
new_ec_test(spaces_before_section_name whitespace.in test8.c
    "^key=value[ \t\n\r]*$")

# test spaces after section name
new_ec_test(spaces_after_section_name whitespace.in test9.c "^key=value[ \t\n\r]*$")

# test spaces at beginning of line between properties
new_ec_test_multiline(spaces_before_middle_property_ML whitespace.in test10.c
    "key1=value1[ \t]*[\n\r]+key2=value2[ \t]*[\n\r]+key3=value3[ \t\n\r]*")

# Tests for comment parsing

# test comments ignored before properties
new_ec_test(comment_before_props comments.in test3.c
    "^key=value[ \t\n\r]*$")

# test comments ignored between properties
new_ec_test_multiline(comment_between_props_ML comments.in test4.c
    "key1=value1[ \t]*[\n\r]+key2=value2[ \t\n\r]*")

# test semicolons at end of property value are included in value
new_ec_test(semicolon_in_property comments.in test5.c
    "^key=value; not comment[ \t\n\r]*$")

# test escaped semicolons are included in section names
new_ec_test(escaped_semicolon_in_section comments.in "test;.c"
    "^key=value[ \t\n\r]*$")

# test octothorpe comments ignored before properties
new_ec_test(octothorpe_comment_before_props comments.in test9.c
    "^key=value[ \t\n\r]*$")

# test octothorpe comments ignored between properties
new_ec_test_multiline(octothorpe_comment_between_props_ML comments.in test10.c
    "key1=value1[ \t]*[\n\r]+key2=value2[ \t\n\r]*")

# test octothorpe at end of property value are included in value
new_ec_test(octothorpe_in_value comments.in test11.c
    "^key=value# not comment[ \t\n\r]*$")

# test escaped octothorpes are included in section names
new_ec_test(escaped_octothorpe_in_section comments.in "test\#.c"
    "^key=value[ \t\n\r]*$")

# test EditorConfig files with BOM at the head
new_ec_test(bom_at_head bom.in "a.c" "^key=value[ \t\n\r]*$")

# test EditorConfig files with CRLF line separators
new_ec_test(crlf_linesep crlf.in "a.c" "^key=value[ \t\n\r]*$")

# Test minimum supported lengths of section name, key and value
new_ec_test(min_supported_key_length limits.in test1
    "^aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa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aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa[ \t\n\r]*$")
new_ec_test(min_supported_section_name_length limits.in test3
    "^k1024=v1024[ \t\n\r]*$")

# Empty .editorconfig files
new_ec_test(empty_editorconfig_file empty.in test4 "^[ \t\n\r]*$")
new_ec_test(newlines_only_editorconfig_file newlines_only.in test4 "^[ \t\n\r]*$")
new_ec_test(comments_only_editorconfig_file comments_only.in test4 "^[ \t\n\r]*$")
new_ec_test(comments_and_newlines_editorconfig_file comments_and_newlines.in test4 "^[ \t\n\r]*$")
